package com.ming.mallchat.common.chat.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;

/**
 * 会话列表
 * @TableName contact
 */
@TableName(value ="contact")
@Data
public class Contact implements Serializable {
    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * uid
     */
    @TableField(value = "uid")
    private Long uid;

    /**
     * 房间id
     */
    @TableField(value = "room_id")
    private Long room_id;

    /**
     * 阅读到的时间
     */
    @TableField(value = "read_time")
    private LocalDateTime read_time;

    /**
     * 会话内消息最后更新的时间(只有普通会话需要维护，全员会话不需要维护)
     */
    @TableField(value = "active_time")
    private LocalDateTime active_time;

    /**
     * 会话最新消息id
     */
    @TableField(value = "last_msg_id")
    private Long last_msg_id;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    private LocalDateTime create_time;

    /**
     * 修改时间
     */
    @TableField(value = "update_time")
    private LocalDateTime update_time;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Contact other = (Contact) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getUid() == null ? other.getUid() == null : this.getUid().equals(other.getUid()))
            && (this.getRoom_id() == null ? other.getRoom_id() == null : this.getRoom_id().equals(other.getRoom_id()))
            && (this.getRead_time() == null ? other.getRead_time() == null : this.getRead_time().equals(other.getRead_time()))
            && (this.getActive_time() == null ? other.getActive_time() == null : this.getActive_time().equals(other.getActive_time()))
            && (this.getLast_msg_id() == null ? other.getLast_msg_id() == null : this.getLast_msg_id().equals(other.getLast_msg_id()))
            && (this.getCreate_time() == null ? other.getCreate_time() == null : this.getCreate_time().equals(other.getCreate_time()))
            && (this.getUpdate_time() == null ? other.getUpdate_time() == null : this.getUpdate_time().equals(other.getUpdate_time()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getUid() == null) ? 0 : getUid().hashCode());
        result = prime * result + ((getRoom_id() == null) ? 0 : getRoom_id().hashCode());
        result = prime * result + ((getRead_time() == null) ? 0 : getRead_time().hashCode());
        result = prime * result + ((getActive_time() == null) ? 0 : getActive_time().hashCode());
        result = prime * result + ((getLast_msg_id() == null) ? 0 : getLast_msg_id().hashCode());
        result = prime * result + ((getCreate_time() == null) ? 0 : getCreate_time().hashCode());
        result = prime * result + ((getUpdate_time() == null) ? 0 : getUpdate_time().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", uid=").append(uid);
        sb.append(", room_id=").append(room_id);
        sb.append(", read_time=").append(read_time);
        sb.append(", active_time=").append(active_time);
        sb.append(", last_msg_id=").append(last_msg_id);
        sb.append(", create_time=").append(create_time);
        sb.append(", update_time=").append(update_time);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}